package com.back.system.controller;


import com.back.common.api.vo.Result;
import com.back.system.entity.SysUser;
import com.back.system.service.SysUserService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/sys/user")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    /**
     * 根据id查询系统用户
     * @param sysUser
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id获取系统用户", notes = "根据id获取系统用户")
    @GetMapping(value = "/querySysUserById")
    public Result<?> querySysUserById(SysUser sysUser,
                                      @RequestParam(name = "id") String id) {

        return sysUserService.getSysUserById(id);
    }

    /**
     * 系统用户分页列表查询
     * @param sysUser
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @ApiOperation(value = "获取系统用户分页列表", notes = "获取系统用户分页列表")
    @GetMapping(value = "/querySysUserPageList")
    public Result<?> querySysUserPageList(SysUser sysUser,
                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                          HttpServletRequest req) {

        return sysUserService.getSysUserList(pageNo, pageSize);
    }
}
